import pymysql


def excu(sql, param):
    # 四大参数建立连接
    con = pymysql.connect(host="localhost", port=3306, user="root", password="root", db="report")

    # 通过连接创建控制台
    cursor = con.cursor()

    # 执行sql
    cursor.executemany(sql, param)

    # 提交
    con.commit()

    # 关闭资源
    cursor.close()
    con.close()


if __name__ == '__main__':
    sql = 'INSERT INTO person VALUES(%s,%s,%s,%s)'
    param = [
        ['小李', 20, '男', 170],
        ['小王', 22, '女', 170],
        ['小张', 23, '男', 180],
        ['小田', 24, '女', 160],
        ['小花', 25, '女', 167],
        ['小美', 26, '男', 181],
        ['小郑', 27, '男', 185],
        ['小卢', 28, '女', 165],
        ['小史', 29, '男', 175],
        ['小曹', 30, '女', 163]
    ]
    excu(sql, param)